// Person.h
#include <iostream>
#include <string>
using namespace std;
class Person
{
public:
    Person() { cout << "Person()\n"; }
    virtual ~Person() { cout << "~Person()\n"; }
};

class Student : public Person // 公有继承
{
public:
    Student() { cout << "Student()\n"; }
    virtual ~Student() { cout << "~Student()\n"; }
};

int main()
{
    Person *p = new Student;
    // 类向下转换
    Student *stu = dynamic_cast<Student*>(p);
    delete p;
    p = nullptr;
    return 0;
}